package com.legrand.core.exception;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * @author xiah
 * 2018-07-10 06:06:18
 */
public abstract class AbstractBaseException extends RuntimeException implements Serializable {

    private static final long serialVersionUID = -864320310069226276L;

    private Exceptions exceptions;

    public abstract Exceptions getExceptions();

    public AbstractBaseException() {
        super(" ");
        this.exceptions = getExceptions();
    }

    public AbstractBaseException(final String devMessage) {
        super(devMessage);
        this.exceptions = getExceptions();
        if (StringUtils.isNotBlank(devMessage)) {
            this.exceptions.setDevMessage(devMessage);
        }

    }

    public AbstractBaseException(final Throwable cause) {
        super(cause);
        this.exceptions = getExceptions();
    }

    public AbstractBaseException(final String devMessage, final String usrMessage) {
        this(devMessage);
        if (StringUtils.isNotBlank(usrMessage)) {
            this.exceptions.setUsrMessage(usrMessage);
        }

    }

    public AbstractBaseException(final String devMessage, final String usrMessage, final Throwable cause) {
        this(devMessage, usrMessage);
    }


}
